package com.juli.school.service.impl;

import java.util.List;

import javax.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.juli.school.dao.entity.Property;
import com.juli.school.dao.entity.Pub;
import com.juli.school.dao.mapper.PropertyMapper;
import com.juli.school.utils.core.model.CommonResp;
import com.juli.school.utils.core.model.ListResp;

/**
 * @Description: TODO
 * @author: wjp
 * @date: 2018年2月7日下午9:31:03
 */
@Service
public class PropertyService {

	@Resource
	PropertyMapper propertyMapper;

	public CommonResp<ListResp<Property>> getlist(Property p) {
		CommonResp<ListResp<Property>> commonResp = new CommonResp<ListResp<Property>>();
		try {
			if (StringUtils.isBlank(p.getPropertyKey())) {
				throw new Exception("参数标识不可为空");
			}
			if(StringUtils.isBlank(p.getStatus())){
				p.setStatus("启用");
			}
			List<Property> list = propertyMapper.list(p);
			ListResp<Property> listResp = new ListResp<Property>();
			listResp.setList(list);
			commonResp.setData(listResp);
			commonResp.success();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return commonResp;
	}
}
